﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class AdminTool_Default : System.Web.UI.Page
{
    private string letterId = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            CreateLetter();
        }
    }

    protected int IsExist()
    {
        int i = 0;

        return i;
    }
    public void CreateLetter()
    {

        string s = Session.SessionID;
        letterId = CutFiveChar(s);
        Literal1.Text = letterId;
    }

    protected void btnLogin_Click1(object sender, EventArgs e)
    {
        letterId = Literal1.Text;
        if (letterId.Trim() == txtCode.Text.Trim())
        {
            int t = IsExist();
            if (t > 0)
            {
                Session.Add("Admin", t);
                Response.Redirect("WelcomeAdmin.aspx");
            }
        }
        lblError.Text = "Không hợp lệ";
        CreateLetter();
    }
    public string CutFiveChar(string s)
    {
        Random rand = new Random();
        int k = rand.Next(0, s.Length - 5);
        string l = s.Substring(k, 5);
        return l;
    }

}
